<link rel="stylesheet" href="{{asset('manger/plugins/layui2.0/css/layui.css')}}" media="all" />
<div class="box box-info">
<div class="box-body">

    <div class="col-sm-8">
<form action="" method="get">

        <div class="row" >
            <div class="col-lg-6">
                <div class="input-group">

                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input type="text" class="layui-input" style="width: 400px" width="400px" id="datetime" name="searchTime" value="{{Request::input('searchTime') ?? ''}}" placeholder="日期范围搜索">


                </div>
            </div>
            <div class="col-lg-6">
                <div class="input-group">
            <button type="submit" class="btn btn-info" data-loading-text="<i class='fa fa-spinner fa-spin '></i> 保存">搜索</button>
                </div>
            </div>
        </div>
</form>

    </div>

    <table class="table table-bordered">
        <tbody>
        <tr>
            <td>企业名称：</td>
            <td>票型名称</td>
            <td>单价:</td>
            <td>订单总数</td>
            <td>已捡数量：</td>
            <td>未捡数量</td>
            <td>退票数量</td>
            <td>订单金额(元)</td>
            <td>已检金额(元)</td>
            <td>未捡金额(元)</td>
            <td>退票手续费(元)</td>
            <td>退票金额(元)</td>
        </tr>
        @php
            $total_total=0;
            $send_total=0;
        $total_zhilv=0;
        $send_zhilv=0;
        $refund_total=0;
        $refund_zhilv=0;
        @endphp
        @foreach($combo as $k=>$item)
        <tr>
            @php
            $totalTotal=$total[$item->id]->total ?? 0;
            $sendTotal=$sendTicket[$item->id]->total ?? 0;
            $totalZhilv=$total[$item->id]->zhilv ?? 0;
            $sendZhilv=$sendTicket[$item->id]->zhilv  ?? 0;

            $total_total+=$total[$item->id]->total ?? 0;
            $send_total+= $sendTotal;
            $total_zhilv+=$totalZhilv;
            $send_zhilv+=$sendZhilv;
            $refund_total+=$refundTicket[$item->id]->total ?? 0;
            $refund_zhilv+=$refundTicket[$item->id]->zhilv ?? 0;

            @endphp
      @if($k==0)      <td rowspan="{{$combo->count()}}">商品名称</td> @endif
            <td>{{$item->title}}</td>
            <td>{{$item->zhilv_price}}</td>
            <td>{{$total[$item->id]->total ?? 0}}</td>
            <td>{{$sendTicket[$item->id]->total ?? 0}}</td>
            <td>{{$totalTotal-$sendTotal}}</td>
            <td>{{$refundTicket[$item->id]->total ?? 0}}</td>
          <td>{{$total[$item->id]->zhilv ?? 0}}</td>
          <td>{{$sendTicket[$item->id]->zhilv ?? 0}}</td>
          <td>{{$totalZhilv -$sendZhilv}}</td>
          <td>0</td>
          <td>{{$refundTicket[$item->id]->zhilv ?? 0}}</td>
        </tr>
@endforeach

        <tr>
            <td></td>
            <td>小计</td>
            <td></td>
            <td>{{$total_total}}</td>
            <td>{{$send_total}}</td>
            <td>{{$total_total-$send_total}}</td>
            <td>{{$refund_total}}</td>
            <td>{{$total_zhilv}}</td>
            <td>{{$send_zhilv}}</td>
            <td>{{$total_zhilv-$send_zhilv}}</td>
            <td>0</td>
            <td>{{$refund_zhilv}}</td>
        </tr>
        <tr>

            <td>总计</td>
            <td></td>
            <td></td>
            <td>{{$total_total}}</td>
            <td>{{$send_total}}</td>
            <td>{{$total_total-$send_total}}</td>
            <td>{{$refund_total}}</td>
            <td>{{$total_zhilv}}</td>
            <td>{{$send_zhilv}}</td>
            <td>{{$total_zhilv-$send_zhilv}}</td>
            <td>0</td>
            <td>{{$refund_zhilv}}</td>
        </tr>
        </tbody>
    </table>
</div>
</div>
<script type="text/javascript" src="{{asset('manger/plugins/layui2.0/layui.js')}}"></script>
<script>
    layui.use('laydate',function(){
        var laydate=layui.laydate;
        laydate.render({
            elem: '#datetime'
            ,type: 'datetime'
            ,range: '~'
        });
    });

</script>